<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>

<script src="lib/vue-2.4.0.js"></script>

</head>

<body>

     <div id="app">
            <mycom1></mycom1>
            <hr>
            <mycom1></mycom1>
            <hr>
            <mycom1></mycom1>
            <hr>
     </div>

     <template id="temp1">
         <div>
            <input type="button" value="+1" @click='increment'> 
            <h3>{{count}}</h3>
         </div>
     </template>

     <script>
         var dataObj = { count: 0 }
         Vue.component('mycom1',{
            template:'#temp1',
            data(){
                return  dataObj   // 由于 这个是个对象引用类型 每次重新调用都指向改obj因此会导致一起变化
                
            },
            methods: {
                increment(){
                    this.count++;
                }
            },
         })
        var vm = new Vue({
             el : '#app',
             data : {
             msg :'' 
            }
        }) 

     </script>

</body>

</html>